package org.onosproject.ngsdn.tutorial.cli;

import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.ngsdn.tutorial.RouterComponent;

@Service
@Command(scope = "onos", name = "encrypt",
        description = "Enable Encrypted")
public class EncryptCommand extends AbstractShellCommand {
    static final String TRUE = "true";
    static final String FALSE = "false";

    @Argument(index = 0, name = "enable",
            description = "Enable entrypt or not (true | false)",
            required = true)
    String enable = null;
    @Override
    protected void doExecute() throws Exception {
        RouterComponent app = get(RouterComponent.class);
        if (enable.equals(TRUE)) {
            app.setEncrypted(true);
        } else if (enable.equals(FALSE)) {
            app.setEncrypted(false);
        }
    }
}
